Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #897 +/- ##
=========================================
Coverage 99.71% 99.71%
- Complexity 1970 1979 +9
=========================================
Files 147 147
Lines 4488 4502 +14
=========================================
+ Hits 4475 4489 +14
Misses 13 13 ☔ View full report in Codecov by Harness. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
This does not do what it's supposed to do. Bad claude. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #838.
Problem
A variable assigned a literal has no type:
Cause
A variable takes the type of the expression assigned to it, through
ExpressionResolver::resolve(). That method had no case for literals, so they resolved to nothing.Change
ExpressionResolver::resolve()gives a literal the narrowest PHP type that names its value:int. One too large forintis a float in PHP, and the parser reads it as one:floatfloatstring__LINE__:int; every other magic constant:stringtrue,false,null: the standalone typestrue,false,nullPHP reads
true,false, andnullas literals in any letter case, but only after aliases and namespaces apply to the name.use const Foo\BAR as true;makestrue(notTRUE, since constant aliases match letter case exactly) nameFoo\BAR, andB\trueis a namespaced constant. The parser's name resolution follows the same rules, so the check compares the resolved name, whole, ignoring letter case.Visible behavior
true,false, ornullshows the type. Before, lowercase showed nothing and uppercase showedconst TRUE.Known limits
??still resolves to the first branch that resolves. Because literals now resolve, a literal written first wins:$c ? null : new User()resolves tonullwhere it used to resolve toUser. PHP gives?User. Likewise$arr['k'] ?? 0used to have no type, because the array read does not resolve, and now resolves toint. Conditional typing is tracked as a whole in Conditional expressions must take the type of every branch they can produce #896, andtests/EndToEnd/defects/896-null-first-ternary.phpreproduces the null-first case. Withoutnullresolving, that case passes.-1), and arithmetic are not literals and stay untyped.testArrowFunctionResolvesThroughToItsEnclosingFunctionexpected no type for$outer = 1;; it now expectsint.🤖 Generated with Claude Code